<!DOCTYPE html>
<html lang="en">
<head>
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width,height=device-height">
  <meta charset="UTF-8">
  <meta name="Author" content="haley">
  <meta name="Keywords" content="数组乱序,打乱顺序">
  <meta name="Description" content="最常用的UI插件">
  <script crossorigin="anonymous" integrity="sha384-6ePHh72Rl3hKio4HiJ841psfsRJveeS+aLoaEf3BWfS+gTF0XdAqku2ka8VddikM" src="https://lib.baomitu.com/jquery/1.11.3/jquery.min.js"></script>
  <link crossorigin="anonymous" integrity="sha384-pdapHxIh7EYuwy6K7iE41uXVxGCXY0sAjBzaElYGJUrzwodck3Lx6IE2lA0rFREo" href="https://lib.baomitu.com/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
  <link href="../../../css/page.css" rel="stylesheet">
  <script crossorigin="anonymous" integrity="sha384-pPttEvTHTuUJ9L2kCoMnNqCRcaMPMVMsWVO+RLaaaYDmfSP5//dP6eKRusbPcqhZ" src="https://lib.baomitu.com/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <script crossorigin="anonymous" integrity="sha384-8t+aLluUVnn5SPPG/NbeZCH6TWIvaXIm/gDbutRvtEeElzxxWaZN+G/ZIEdI/f+y" src="https://lib.baomitu.com/vue/2.6.10/vue.min.js"></script>
  <script src="../../../js/page.js"></script>
  <script src="../../../js/changeTitle.js"></script>
  <link href="../../../imgs/favicon.ico" rel="shortcut icon">
  <script src="../../../js/goToHome.js"></script>
  <title></title>
  <script>
    var data={
      title:'字符串相关',
      content:{
        intro:{
          list:[
            {
              title:'使用说明：',
              className:'bs-callout-info',
              list:[
                {title:'基础配置：',content:'无'}
                ,{title:'如何使用：',content:'直接复制本文件js源码'}
              ]
            }
          ]
        }
      }
    };
  </script>
</head>
<body>
<div id="page">
  <div class="container">
    <h3 class="text-center">{{title}}</h3>
    <div class="bs-callout" :class="item.className" v-for="item in content.intro.list">
      <h4>{{item.title}}</h4>
      <ul>
        <li v-for="item2 in item.list"><b>{{item2.title}}</b>{{item2.content}}</li>
      </ul>
    </div>
  </div>
  <script>
    var page = new Vue({
      el: '#page',
      data: data
    });
  </script>
</div>

<div class="container">
  <section class="panel panel-info">
    <div class="panel-heading">转义html标签</div>
    <div class="panel-body">
      <!--核心代码 s-->
      <div class="row">
        <div class="col-sm-12">
          <div class="">
            <p>
<pre>
  function html2Escape(sHtml) {
     return sHtml.replace(/[<>&"]/g,function(c){return {'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'}[c];});
  }
  console.log(html2Escape('&lt;h2 class="title">标题&lt;/h2>')); // &lt; h2 class=&quot;title&quot;&gt;标题&lt;/h2&gt;
</pre>
            </p>
          </div>
          <!--核心js-->
          <script>
            function html2Escape(sHtml) {
              return sHtml.replace(/[<>&"]/g,function(c){return {'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'}[c];});
            }
           console.log(html2Escape('<h2 class="title">标题</h2>'));//&lt;h2 class=&quot;title&quot;&gt;标题&lt;/h2&gt;
          </script>
          <!--核心js-->
        </div>
      </div>
      <!--核心代码 e-->
    </div>
  </section>
  <section class="panel panel-info">
    <div class="panel-heading">转义符换成普通html字符</div>
    <div class="panel-body">
      <!--核心代码 s-->
      <div class="row">
        <div class="col-sm-12">
          <div class="">
            <p>
<pre>
  function escape2Html(str) {
    var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
    return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
  }
  console.log(escape2Html('&lt;h2 class=&quot;title&quot;&gt;标题&lt;/h2&gt;')); //&lt;h2 class=&quot;title&quot;&gt;标题&lt;/h2&gt;
</pre>
            </p>
          </div>
          <!--核心js-->
          <script>
            function escape2Html(str) {
              var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
              return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
            }
           console.log(escape2Html('&lt;h2 class=&quot;title&quot;&gt;标题&lt;/h2&gt;'));//
          </script>
          <!--核心js-->
        </div>
      </div>
      <!--核心代码 e-->
    </div>
  </section>
</div>

</body>

</html>
